﻿Public Class Cleaner

    Private Path As String
    Private language As String
    Private l As New language

    Public Sub New(ByVal p As String)
        Path = p
        language = l.get_lan(Path)
    End Sub

    Private Sub _remove(ByVal sign As String)
        For Each FoundFile As String In FileIO.FileSystem.GetFiles(Path, FileIO.SearchOption.SearchAllSubDirectories, sign)
            FileIO.FileSystem.DeleteFile(FoundFile)
        Next
    End Sub

    Public Sub cleantree()
        Dim deffile As String
        deffile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\Omnisource\" & language & ".trash"
        If FileIO.FileSystem.FileExists(deffile) Then
            Dim reader As New System.IO.StreamReader(deffile)
            Do While reader.Peek() <> -1
                _remove(reader.ReadLine() & vbNewLine)
            Loop
        Else
            defn.ShowDialog()
        End If
    End Sub

End Class
